import React,{ useEffect } from "react";

import { useLocation } from 'react-router-dom';
 
const Product = () => {
  const location = useLocation();
  const queryParams = new URLSearchParams(location.search);
  const id = queryParams.get('id'); // 获取查询参数 id

  useEffect(() => {
    console.log(location)
  }, []); // 传空数组，
 
  return (
    <div>
      <h2>产品页面</h2>
      <p>当前产品 ID: {id}</p>
    </div>
  );
}
 
export default Product;